<?php
	class diemthilaidb
	{
		public function Add($MaHocSinh,$MaMonHoc,$DiemThi,$DiemTB,$HocKy,$NamHoc)
		{
			$sql = "INSERT INTO `tbl_diemthilai`(`MaHocSinh`, `MaMonHoc`, `DiemThi`, `DiemTB`, `HocKy`, `NamHoc`) 
			VALUES ('$MaHocSinh',$MaMonHoc,$DiemThi,$DiemTB,'$HocKy','$NamHoc')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
	
		public function Update($MaHocSinh,$MaMonHoc,$DiemThi,$DiemTB,$HocKy,$NamHoc)
		{
			$sql = "UPDATE `tbl_diemthilai` 
					SET DiemThi = $DiemThi,
						DiemTB = $DiemTB
					 WHERE MaHocSinh = '$MaHocSinh' AND MaMonHoc = $MaMonHoc AND HocKy = '$HocKy' AND NamHoc = '$NamHoc' "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
		public function GetList($MaHocSinh,$MaMonHoc,$DiemThi,$DiemTB,$HocKy,$NamHoc)
		{
			$sql = " SELECT * FROM `tbl_diemthilai`,`tbl_diemhk`,`tbl_monhoc` WHERE tbl_diemthilai.MaHocSinh = tbl_diemhk.MaHocSinh AND  tbl_diemthilai.MaMonHoc = tbl_diemhk.MaMonHoc AND  tbl_diemthilai.HocKy = tbl_diemhk.HocKy AND tbl_diemthilai.NamHoc = tbl_diemhk.NamHoc AND tbl_diemhk.MaMonHoc = tbl_monhoc.MaMonHoc ";
			if($MaHocSinh!="")
				$sql .= " AND tbl_diemthilai.MaHocSinh = '$MaHocSinh' ";
			if($MaMonHoc!="")
				$sql .= " AND tbl_diemthilai.MaMonHoc = $MaMonHoc ";
			if($DiemThi!="")
				$sql .= " AND tbl_diemthilai.DiemThi = $DiemThi ";
			if($DiemTB!="")
				$sql .= " AND tbl_diemthilai.DiemTB = $DiemTB ";
			if($HocKy!="")
				$sql .= " AND tbl_diemthilai.HocKy ='$HocKy' ";
			if($NamHoc!="")
				$sql .= " AND tbl_diemthilai.NamHoc = '$NamHoc' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>